package cur.nature.gateway;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextClosedEvent;

@Configuration
public class GatewayListener {
    private static Logger LOG = LoggerFactory.getLogger(GatewayListener.class);

    @Bean
    public ApplicationListener onGatewayStart() {
        return (ApplicationListener<ApplicationReadyEvent>) event -> {
            LOG.info("Gateway started-------------------------------");
        };
    }

    @Bean
    public ApplicationListener onGatewayStop() {
        return (ApplicationListener<ContextClosedEvent>) event -> {
            LOG.info("Gateway stopped-------------------------------");
        };
    }
}
